function searchAll(domain) {
	domain = domain || location.hostname;
	
	var portalFlag = $("#portalFlag").val() || 0;
	var searchType = $("#searchTypeInp").val();
	var searchKey = $.trim($("#searchKey").val());
	if(searchKey == "" || searchKey == "请输入检索关键字" || searchKey == "请输入课程" || searchKey == "搜索课程") {
		alert("请输入检索关键字");
		return false;
	}
	searchKey=stripscript(searchKey);
	var param = "";
	if (searchType == 0) { // 超星发现搜索
		param = "<input type=\"hidden\" name=\"sw\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://ss.chaoxing.com/search");
		
	}else if(searchType == 1) { // 公告通知搜索
		param = "<input type=\"hidden\" name=\"searchKey\" value=\""+searchKey+"\"/>";
		
		var submitUrl = portalFlag > 0 ? "http://" + domain + "/portal/news/notice/"+portalFlag :"http://" + domain + "/portal/news/notice";
		submitForm(param, submitUrl);
	}
	else if(searchType == 2) { // 本校课程搜索
		param = "<input type=\"hidden\" name=\"courseName\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/portal/schoolCourseInfo/department");
	}
	else if(searchType == 3) { // 全校课程搜索
		var curuserId = $("#curuserId").val();
		if(curuserId > 0) {
			domain = "nation.chaoxing.com";
			var unitprefix = $("#unitprefix").val();
			var nationDESStr = $("#nationDESStr").val();
			param = "<input type=\"hidden\" name=\"courseName\" value=\""+searchKey+"\"/><input type=\"hidden\" name=\"prefix\" value=\""+unitprefix+"\"/><input type=\"hidden\" name=\"id\" value=\""+nationDESStr+"\"/>";
			submitForm(param, "http://" + domain + "/courseinfo/lucene/searchkc");
		} else {
			alert("您需要登录才能访问该栏目！");
			return false;
		}
	} 
	else if (searchType == 4) { // 课程网站课程
		param = "<input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/portal/schoolCourseInfo/curriculum");
	}
	else if (searchType == 5) { // 课程库课程,列表结果页面
		param = "<input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		
		var submitUrl = portalFlag > 0 ? "http://" + domain + "/portal/courseNetwork/list/"+portalFlag :"http://" + domain + "/portal/courseNetwork/list";
		submitForm(param, submitUrl);
	}else if (searchType == 6) { // 浙江金融讲座视频搜索
		param = "<input type=\"hidden\" name=\"kw\" value=\""+searchKey+"\"/><input type=\"hidden\" name=\"webType\" value=\"2\"/><input type=\"hidden\" name=\"pageSize\" value=\"12\"/>";
		submitForm(param, "http://zfckc.fy.chaoxing.com/search.html");
	}else if (searchType == 7) { // 根据授课教师搜索课程
		param = "<input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		
		var submitUrl = "http://" + domain + "/portal/courseNetwork/teacher";
		submitForm(param, submitUrl);
	}
	else if (searchType == 8) { // 课程库课程,大图结果页面
		param = "<input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		
		var submitUrl = portalFlag > 0 ? "http://" + domain + "/portal/courseNetwork/index/"+portalFlag :"http://" + domain + "/portal/courseNetwork/index";
		submitForm(param, submitUrl);
	}
	else if (searchType == 9) { // 视频公开课检索，嘉兴学院定制
		var curuserId = $("#curuserId").val();
		if(curuserId > 0) {
			domain = "video.fy.chaoxing.com";
			param = "<input type=\"hidden\" name=\"coursename\" value=\""+searchKey+"\"/>";
			submitForm(param, "http://" + domain + "/hotVideoPageList");
		} else {
			alert("您需要登录才能访问该栏目！");
			return false;
		}
	}
	else if (searchType == 10) { // 证书查询，教师发展中心定制
		param = "<input type=\"hidden\" name=\"sw\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/portal/certificate/search");
	}
	else if (searchType == 11) { // 爱中医单位定制课程列表内检索
		var param = "<input type=\"hidden\" name=\"courseName\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/fanya/courselist");
	}
	else if (searchType == 12) { // 超星发现dz搜索
		param = "<input type=\"hidden\" name=\"sw\" value=\""+searchKey+"\"/>";
		submitForm(param, "/zhizhendz");
		
	}
	else if (searchType == 13) { // 新增课程教师检索
		var param = "<input type=\"hidden\" name=\"teachername\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/portal/courseNetwork/searchteacourse");
	}
	else if (searchType == 14) { // 教师用户检索
		var param = "<input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/portal/classteacher/search");
	}
	else if(searchType.length > 3) {  // 栏目内检索
		param = "<input type=\"hidden\" name=\"columnId\" value=\""+searchType+"\"/><input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/portal/schoolCourseInfo/columnCourse");
	}
	else if (searchType == 15) { // 联盟课程
		var param = "<input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/portal/league/getcourses");
	}
	else if (searchType == 16) { //课程分类检索
		var param = "<input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/fanya/courselist");
		
	}
	else if (searchType == 17) { //精品课程检索
		var param = "<input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		
		var submitUrl = portalFlag > 0 ? "http://" + domain + "/portal/schoolCourseInfo/favoriteCourse/"+portalFlag :"http://" + domain + "/portal/schoolCourseInfo/favoriteCourse";
		submitForm(param, submitUrl);
	}
	else if (searchType == 18) { //尔雅课程检索
		var param = "<input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://" + domain + "/portal/courseNetwork/eryaCourse2");
		
	}
	else if (searchType == 19) { //华理校外课程检索
		var param = "<input type=\"hidden\" name=\"columnId\" value='85873'/><input type=\"hidden\" name=\"keyword\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://yjsecust.boya.chaoxing.com/portal/schoolCourseInfo/columnCourse3");
		
	}
	else if (searchType == 20) { //尔雅课程检索
		var param = "<input type=\"hidden\" name=\"val\" value=\""+searchKey+"\"/>";
		submitForm(param, "http://erya.mooc.chaoxing.com/search","get","_blank");
		
	}
}

function stripscript(s)
{
	var pattern = new RegExp("[%--`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");        //格式 RegExp("[在中间定义特殊过滤字符]")
	var rs = "";
	for (var i = 0; i < s.length; i++) {
	 rs = rs+s.substr(i, 1).replace(pattern, '');
	}
	return rs;
}

function submitForm(param,action,target) {
	target = target || "";
	var subForm = $("#searchAllFrom").length;
	if(subForm > 0) {
		$("#putData").html(param);
		$("#searchAllFrom").attr("action",action);
		if(target != "") {
			$("#searchAllFrom").attr("target",target);
		}
		$("#searchAllFrom").submit();
	}else {
		var form = $("<form></form>")
        form.attr('action',action)
        form.attr('method','get')
        if(target != "") {
        	form.attr("target",target);
		}
        form.append(param)
        form.appendTo("body")
        form.css('display','none')
        form.submit();
	}
}